define(function(require, exports, module){
	/**
	 * 错误代码定义
	 */
	var ERROR_CODE = {
		TOKEN_ERROR : 10001,
		PARAM_ERROR : 10002,
		API_ERROR : 10003,
	};

	/**
	 * 错误基类
	 */
	function Error(message, code) {
		this.message = message || '';
		this.code = code || 0;
	}
	Error.prototype = {
		toString: function(){
			return this.message;
		}
	};
	

	/** 
	 * 令牌错误
	 */
	function TokenError(message) {
		Error.call(this, message, ERROR_CODE.TOKEN_ERROR);
	}
	TokenError.prototype = $.extend(new Error(), {});
	


	/**
	 * 主要是api调用出错，网络问题，未验证Token
	 */
	function ApiError(error){
		Error.call(this, error, ERROR_CODE.API_ERROR);
	}
	ApiError.prototype = new Error();

	/**
	 * 参数验证失败
	 */
	function ParamError(errors) {
		this.errors = errors;
		Error.call(this, '参数验证失败', ERROR_CODE.PARAM_ERROR);
	}
	ParamError.prototype = new Error();

	/**
	 * 逻辑错误
	 */
	function LogicError(error, code) {
		this.error = error;
		this.code = code;

		Error.call(this, error, code)
	}
	LogicError.prototype = new Error();

	/**
	 * 导出
	 */
	exports.ERROR_CODE = ERROR_CODE;
	exports.Error = Error;
	exports.TokenError = TokenError;
	exports.ApiError = ApiError;
	exports.ParamError = ParamError;
	exports.LogicError = LogicError;	
});